selenium中的java用户登录身份验证?
我在excel工作表中有一个username
和password
的列表
我正在尝试查找登录页的有效用户凭据
这是我的代码:
Workbook wBook = null;
try {
wBook = Workbook.getWorkbook(new File("C:/Users/jayant.gupta/Desktop/Book1.xls"));
} catch (BiffException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//get sheet
jxl.Sheet s = wBook.getSheet(0);
for(int i=0;i<s.getRows();i++)
{
for(int j=0;j<s.getColumns();j++)
{
Cell cell=s.getCell(j, i);
System.out.println(" "+cell.getContents());
System.out.println("i "+i);
System.out.println("j "+j);
if(j==0){
driver.findElement(By.id("textBoxUserName")).sendKeys(cell.getContents());
}
if(j==1){
driver.findElement(By.id("txtPswd")).sendKeys(cell.getContents());
driver.findElement(By.id("explore")).click();
driver.findElement(By.id("textBoxUserName")).clear();
driver.findElement(By.id("txtPswd")).clear();
}
}
System.out.println("\n");
}
我在excel中总共有6个登录凭据。从中只有1个是有效凭证,位于excel的位置4
当我到达excel的第四个位置时,它会将我带到下一页
但是我想检查下两个登录凭据是否有效
我该怎么做
# 1 楼答案